/*
  File:    DiffusionSolverSteadyState.h
  Purpose: Provides a fully nonlinear diffusional solver 
           for steady state problems, using our brand new ideas. 
		  In particular, it solves the problem 
		   
		  0 = div( DiffusionConstant(u,x,y) . grad(u) ) + Sources(u,x,y)
		   
		  with boundary conditions on the left, right, bottom, 
		  and top, of type:
		    
		  'D': Dirichlet
		  'N': Neuman
		  'E': Extrapolation/continuity

           Assumed:
           Can evaluate DiffusionConstant, Source, and 
		  boundary conditions at any point (x,y) where 
		  appropriate. 
    
           DiffusionConstant and Source can be nonlinear 
		  in u. 
   
           Result: 
           The solution u(x,y,t) at t+dt.   
		   
  Contact: Paul Macklin
           pmacklin@math.uci.edu
		  http://math.uci.edu/~pmacklin
*/

#include "../Matrix.h"

Matrix NonlinearDiffusionSteadyState( 
   Matrix& X, Matrix& Y, 
   Matrix& InitialGuess ,
   double (*LeftBC)(double),   char LeftBCtype,  
   double (*RightBC)(double),  char RightBCtype,     
   double (*BottomBC)(double), char BottomBCtype,   
   double (*TopBC)(double),    char TopBCtype,  
   double (*DiffusionConstant)(double,double,double,int,int), 
   double (*SourceTimesU)(double,double,double,int,int),
   double (*SourceRemainder)(double,double,double,int,int),
   int MaxIterations, double Tolerance );

Matrix NonlinearDiffusionSteadyStateNonAdaptive( 
   Matrix& X, Matrix& Y, 
   Matrix& InitialGuess ,
   double (*LeftBC)(double),   char LeftBCtype,  
   double (*RightBC)(double),  char RightBCtype,     
   double (*BottomBC)(double), char BottomBCtype,   
   double (*TopBC)(double),    char TopBCtype,  
   double (*DiffusionConstant)(double,double,double,int,int), 
   double (*SourceTimesU)(double,double,double,int,int),
   double (*SourceRemainder)(double,double,double,int,int),
   int MaxIterations, double Tolerance );
   
double ImplicitUpdate(
Matrix& Solution, 
double (*Diffusion)(double,double,double,int,int),
double (*SourceTimesU)(double,double,double,int,int),
double (*SourceRemainder)(double,double,double,int,int), 
int i, int j, 
double x, double y, double dx, double dy );

double UpdateBoundaryPoint( Matrix& Solution, 
   double (*LeftBC)(double),   char LeftBCtype,  
   double (*RightBC)(double),  char RightBCtype,     
   double (*BottomBC)(double), char BottomBCtype,   
   double (*TopBC)(double),    char TopBCtype,  
   int i, int j, 
   double x, double y );
   
double UpdateBoundaryPoint(Matrix& Solution, 
double (*Diffusion)(double,double,double,int,int),
double (*SourceTimesU)(double,double,double,int,int),
double (*SourceRemainder)(double,double,double,int,int), 
int i, int j, 
double x, double y, double dx, double dy );

